# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libtheora

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.1
pkgrel=1
pkgdesc="An open video codec developed by the Xiph.org (mingw-w64)"
arch=('any')
url="http://xiph.org"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-libpng" "${MINGW_PACKAGE_PREFIX}-libogg" "${MINGW_PACKAGE_PREFIX}-libvorbis" "${MINGW_PACKAGE_PREFIX}-SDL" "${MINGW_PACKAGE_PREFIX}-libpng")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("http://downloads.xiph.org/releases/theora/${_realname}-${pkgver}.tar.bz2"
    libtheora-1.1.1-libpng16.patch)
md5sums=('292ab65cedd5021d6b7ddd117e07cd8e'
         '08edd81c7a1be2c4edfd2cd3c112a8c6')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  sed -i "s,EXPORTS,," "win32/xmingw32/libtheoradec-all.def"
  sed -i "s,EXPORTS,," "win32/xmingw32/libtheoraenc-all.def"
  patch -p0 -i ${srcdir}/libtheora-1.1.1-libpng16.patch
}

build() {
  mkdir -p $srcdir/build-$MINGW_CHOST
  cd "$srcdir/build-$MINGW_CHOST"
  ../$_realname-$pkgver/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make -j1
}

package() {
  cd "$srcdir/build-$MINGW_CHOST"
  make install DESTDIR="${pkgdir}"
  #rm -r "${pkgdir}${MINGW_PREFIX}/share"
}
